<script>
init({
  title: 'Update Row',
  desc: 'Update the specified row: `$table.bootstrapTable(\'updateRow\', {index: 1, row: row})`.',
  links: ['bootstrap-table.min.css'],
  scripts: ['bootstrap-table.min.js']
})
</script>

<template>
  <div id="toolbar">
    <button
      id="button"
      class="btn btn-secondary"
    >
      updateRow
    </button>
  </div>
  <table
    id="table"
    data-toggle="table"
    data-toolbar="#toolbar"
    data-height="428"
    data-search="true"
    data-url="json/data1.json"
  >
    <thead>
      <tr>
        <th
          data-field="id"
          data-sortable="true"
        >
          ID
        </th>
        <th
          data-field="name"
          data-sortable="true"
        >
          Item Name
        </th>
        <th
          data-field="price"
          data-sortable="true"
        >
          Item Price
        </th>
      </tr>
    </thead>
  </table>
</template>

<script>
  const $table = $('#table')
  const $button = $('#button')

  function mounted () {
    $button.click(function () {
      const randomId = 100 + ~~(Math.random() * 100)

      $table.bootstrapTable('updateRow', {
        index: 1,
        row: {
          id: randomId,
          name: `Item ${randomId}`,
          price: `$${randomId}`
        }
      })
    })
  }
</script>
